package tiled.simple.gwt.server;

import java.io.InputStream;

import javax.servlet.ServletContext;

import tiled.simple.core.Map;
import tiled.simple.gwt.client.GameService;
import tiled.simple.reader.TMXReader;

import com.google.gwt.user.server.rpc.RemoteServiceServlet;


public class GameServiceImpl extends RemoteServiceServlet implements GameService {
	private static final long serialVersionUID = -7118331187186394472L;

	public Map getGameData() throws IllegalArgumentException {

		
		ServletContext context = getServletContext();
		InputStream is = context.getResourceAsStream("/desert.tmx");
		
		TMXReader tmxReader = new TMXReader();
		
		Map map = null;
		try {
			map = tmxReader.readMap(is);
		} catch (Exception e) {
			System.out.println(e.getMessage());
		}
		
		return map;
	}

}
